
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>异步神器Async Await介绍与填坑 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="灵活运用JS开发技巧.html" />
    
    
    <link rel="prev" href="常用的前端JavaScript方法封装.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../Vue/7个有用的Vue开发技巧.html">
            
                <a href="../Vue/7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                <a href="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../Vue/Vue.set和this.$set应用的场景.html">
            
                <a href="../Vue/Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../Vue/vue高级技巧.html">
            
                <a href="../Vue/vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../Vue/父组件监听到子组件的生命周期.html">
            
                <a href="../Vue/父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="5种常见函数的写法和调用方式.html">
            
                <a href="5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="7道javascript题，让你理解基本的javascript.html">
            
                <a href="7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="ES6汇总资料.html">
            
                <a href="ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="JS开发必须知道的41个技巧.html">
            
                <a href="JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="JavaScript数组求并集，交集和差集.html">
            
                <a href="JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="JavaScript的优雅写法.html">
            
                <a href="JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="axios知识点.html">
            
                <a href="axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="javascript核心知识.html">
            
                <a href="javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="this、apply、call、bind.html">
            
                <a href="this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="前端js常用的60余种工具方法.html">
            
                <a href="前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="前端异常的捕获与处理.html">
            
                <a href="前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="常用的前端JavaScript方法封装.html">
            
                <a href="常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.17" data-path="异步神器Async-await介绍与填坑.html">
            
                <a href="异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="灵活运用JS开发技巧.html">
            
                <a href="灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.21" data-path="编写高质量可维护的代码：优雅命名.html">
            
                <a href="编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="编写高质量可维护的代码：数据建模.html">
            
                <a href="编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >异步神器Async Await介绍与填坑</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#&#x5F02;&#x6B65;&#x795E;&#x5668;async-await&#x4ECB;&#x7ECD;&#x4E0E;&#x586B;&#x5751;"><b>1.1.1. </b>&#x5F02;&#x6B65;&#x795E;&#x5668;Async-await&#x4ECB;&#x7ECD;&#x4E0E;&#x586B;&#x5751;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="&#x5F02;&#x6B65;&#x795E;&#x5668;async-await&#x4ECB;&#x7ECD;&#x4E0E;&#x586B;&#x5751;"><a name="&#x5F02;&#x6B65;&#x795E;&#x5668;async-await&#x4ECB;&#x7ECD;&#x4E0E;&#x586B;&#x5751;" class="anchor-navigation-ex-anchor" href="#&#x5F02;&#x6B65;&#x795E;&#x5668;async-await&#x4ECB;&#x7ECD;&#x4E0E;&#x586B;&#x5751;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. &#x5F02;&#x6B65;&#x795E;&#x5668;Async-await&#x4ECB;&#x7ECD;&#x4E0E;&#x586B;&#x5751;</h3>
<blockquote>
<p>&#x795E;&#xFF0C;&#x8BF7;&#x597D;&#x597D;&#x7814;&#x7A76;&#x4E00;&#x4E0B;async-await&#x529F;&#x80FD;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x4E1A;&#x52A1;&#x9700;&#x6C42;&#x4E2D;&#xFF0C;&#x7528;&#x5904;&#x5DE8;&#x5DE8;&#x5DE8;&#x5DE8;&#x5927;&#xFF0C;&#x8BF7;&#x540C;&#x6211;&#x5B66;&#x4E60;&#xFF0C;&#x6211;&#x6559;&#x4F60;&#x4EEC;&#x3002;</p>
<p>&#x8BF7;&#x6BCF;&#x4E00;&#x884C;&#x6BCF;&#x4E00;&#x53E5;&#x7684;&#x53BB;&#x4E86;&#x89E3;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;&#x4E9B;&#x65B9;&#x6CD5;&#x3002;&#x5751;&#x8981;&#x8BA4;&#x771F;&#x7684;&#x586B;&#xFF0C;&#x522B;&#x88AB;&#x57CB;&#x4E86;</p>
</blockquote>
<h4 id="async---&#x5B9A;&#x4E49;&#x5F02;&#x6B65;&#x51FD;&#x6570;"><a name="async---&#x5B9A;&#x4E49;&#x5F02;&#x6B65;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#async---&#x5B9A;&#x4E49;&#x5F02;&#x6B65;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>async - &#x5B9A;&#x4E49;&#x5F02;&#x6B65;&#x51FD;&#x6570;</h4>
<p> <code>async</code> &#x8BD1;&#xFF1A;&#x5F02;&#x6B65;&#xFF0C;&#x662F; Generator &#x51FD;&#x6570;&#x7684;&#x8BED;&#x6CD5;&#x7CD6;&#x3002;&#x8BE5;&#x51FD;&#x6570;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;promise&#x5BF9;&#x8C61;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>then</code>&#x65B9;&#x6CD5;&#x6DFB;&#x52A0;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#xFF0C;&#x5982;&#x679C;&#x5728;&#x51FD;&#x6570;&#x5185;&#x76F4;&#x63A5; <code>return</code>&#xFF0C;Async&#x4F1A;&#x901A;&#x8FC7;<strong>Promise.resolve()</strong>&#x5C06;&#x5176;&#x5C01;&#x88C5;&#x6210;Promise()&#x5BF9;&#x8C61;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>.then</code>&#x6DFB;&#x52A0;&#x56DE;&#x8C03;&#x51FD;&#x6570;</p>
<blockquote>
<p>async &#x4E3A;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#xFF0C;&#x8BF7;&#x7262;&#x8BB0; &#xFF0C;&#x5982;&#x4E0B;&#x9762;&#x4F8B;&#x5B50;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pms</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;abc&apos;</span>
}
<span class="hljs-built_in">console</span>.log(pms())  <span class="hljs-comment">// [object Promise] { ... }</span>
</code></pre>
<p>  &#x4EE5;&#x4E0A;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x8FD4;&#x56DE;&#x4E86;&#x4E00;&#x4E2A;promise&#x5BF9;&#x8C61;&#xFF0C;&#x5176;&#x6267;&#x884C;&#x7B49;&#x6548;&#x4E8E; </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pms</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> {
    resolve(<span class="hljs-string">&apos;abc&apos;</span>)
  })
}
</code></pre>
<p> &#x5728;&#x6CA1;&#x6709;&#x914D;&#x5408;<code>await</code>&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8C03;&#x7528;promise&#x7684;<code>.then</code>&#x65B9;&#x6CD5;&#x5F97;&#x5230;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x3002;&#x5F53;&#x7136;&#x4E5F;&#x4F1A;&#x6709;<code>.catch</code>&#x65B9;&#x6CD5; </p>
<pre><code class="lang-javascript">pms().then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(res)  <span class="hljs-comment">// &apos;abc&apos;</span>
}).catch(<span class="hljs-function"><span class="hljs-params">e</span> =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x9519;&#x8BEF;&apos;</span>)
})
</code></pre>
<blockquote>
<p>&#x5751;1&#xFF1A;async&#x7684;&#x4F7F;&#x7528;&#xFF0C;&#x6709;await,&#x5C31;&#x4E00;&#x5B9A;&#x8981;async&#xFF0C;&#x725B;&#x903C;&#x4EBA;&#x90FD;&#x5E94;&#x8BE5;&#x80FD;&#x8BB0;&#x4F4F;</p>
</blockquote>
<h4 id="await---&#x6682;&#x505C;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;"><a name="await---&#x6682;&#x505C;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;" class="anchor-navigation-ex-anchor" href="#await---&#x6682;&#x505C;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>await - &#x6682;&#x505C;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;</h4>
<blockquote>
<p>&#x60A8;&#x5386;&#x5BB3;&#x4E86;&#xFF0C;&#x4F60;&#x5386;&#x5BB3;&#x4E86;&#xFF0C;&#x6CA1;&#x6709;&#x4F60;&#x600E;&#x4E48;&#x5904;&#x7406;&#xFF0C;await&#x4E0D;&#x9519;</p>
</blockquote>
<p><code>await</code>&#xFF0C;&#x5373;&#xFF1A;async wait&#xFF0C;&#x65E8;&#x5728;<strong>&#x7B49;&#x5F85;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7ED3;&#x675F;&#xFF0C;&#x4F7F;&#x7528;&#x4E8E;async&#x51FD;&#x6570;&#x5185;&#x90E8;</strong>&#x3002;&#x5F02;&#x6B65;&#x672A;&#x6267;&#x884C;&#x7ED3;&#x675F;&#xFF0C;&#x963B;&#x585E;&#x5F53;&#x524D;&#x4EE3;&#x7801;&#x3002;&#x55EF;&#x54FC;&#xFF1F;<strong>&#x963B;&#x585E;&#xFF01;&#xFF01;&#xFF01;</strong></p>
<p>&#x2002; &#x4E0E;&#x7EBF;&#x7A0B;&#x963B;&#x585E;&#x4E0D;&#x540C;&#x7684;&#x662F;&#xFF0C;<code>await</code> &#x7684;&#x963B;&#x585E;&#x53D1;&#x751F;&#x5728; <code>async</code> &#x51FD;&#x6570;&#x5185;&#x90E8;&#xFF0C;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x7684;&#x963B;&#x585E;&#x3002;&#x8DDF;&#x5728;<code>await</code>&#x540E;&#x7684;JS&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x7B49;&#x5F85;&#x5F88;&#x591A;&#x7C7B;&#x578B;&#x7684;&#x4E8B;&#x4EF6;&#xFF0C;&#x4F46;&#x521D;&#x8877;&#x662F;&#x7528;&#x4E8E;&#x7B49;&#x5F85;<strong>Promise</strong>&#x5BF9;&#x8C61;&#x3002;&#x5982;&#x679C;<code>await</code>&#x7684;&#x5BF9;&#x8C61;&#x662F;promise&#x5BF9;&#x8C61;&#xFF0C;&#x5219;&#x963B;&#x585E;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#x4EE3;&#x7801;&#x6267;&#x884C;&#x7B49;&#x5F85;promise&#x7684;<code>resolve</code>&#x72B6;&#x6001;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x540C;&#x6B65;&#x6267;&#x884C;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x5219;&#x7ACB;&#x5373;&#x6267;&#x884C;&#x3002;</p>
<h4 id="asyncawait&#x7684;&#x4F7F;&#x7528;"><a name="asyncawait&#x7684;&#x4F7F;&#x7528;" class="anchor-navigation-ex-anchor" href="#asyncawait&#x7684;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>async/await&#x7684;&#x4F7F;&#x7528;</h4>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">asyncFunc</span>(<span class="hljs-params">time</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> {
    setTimeout(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> {  <span class="hljs-comment">// &#x7528;setTimeout&#x6A21;&#x62DF;&#x5F02;&#x6B65;</span>
      resolve(<span class="hljs-string">&apos;async result&apos;</span>)
    }, time)
  })
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">normalFunc</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;normal result&apos;</span>)
}

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">awaitDemo</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">await</span> normalFunc()  <span class="hljs-comment">// &#x6267;&#x884C;&#x7ACB;&#x5373;&#x6253;&#x5370; normal result</span>
  <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> asyncFunc(<span class="hljs-number">1000</span>)
  <span class="hljs-built_in">console</span>.log(res) <span class="hljs-comment">// &#x6267;&#x884C;1s&#x540E;&#x6253;&#x5370; &#x2018;async result&#x2019;</span>
}

awaitDemo() <span class="hljs-comment">// &#x6267;&#x884C;</span>
</code></pre>
<p> &#x4EE5;&#x4E0A;&#x7684;&#x4F8B;&#x5B50;&#x6BD4;&#x8F83;&#x5E38;&#x89C4;&#xFF0C;&#x518D;&#x770B;&#x770B;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50; </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">func</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;123&apos;</span>)
}
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">run</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> func()
  <span class="hljs-built_in">console</span>.log(res)  <span class="hljs-comment">// 123</span>
}
run()
</code></pre>
<p>&#x8BE5;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;<code>func</code>&#x770B;&#x4F3C;&#x4E00;&#x4E2A;&#x666E;&#x901A;&#x51FD;&#x6570;&#xFF0C;&#x4F46;&#x7ECF;<code>async</code>&#x5B9A;&#x4E49;&#x540E;&#xFF0C;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;<strong>promise</strong>&#x5BF9;&#x8C61;&#xFF0C;&#x6B64;&#x65F6;&#x7684;<code>await</code>&#x7B49;&#x5F85;&#x7684;&#x5C31;&#x662F;&#x8BE5;<strong>promise</strong>&#x5BF9;&#x8C61;&#x7684;<code>resolve</code>&#x53C2;&#x6570;&#xFF0C;&#x5373;<code>123</code>&#x3002;
  &#x5BF9;&#x6BD4;&#x4E0A;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#x7684;<code>normalFunc</code>&#xFF0C;&#x4E3B;&#x8981;&#x6709;&#x4E24;&#x4E2A;&#x7406;&#x89E3;&#x70B9;
 &#xFF08;1&#xFF09;&#x589E;&#x52A0;&#x4E86;<strong>async</strong>&#x7684;&#x666E;&#x901A;&#x51FD;&#x6570;&#x53D8;&#x6210;&#x4E86;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#xFF0C;<strong>await</strong>&#x7B49;&#x5F85;&#x7684;&#x5BF9;&#x8C61;&#x4E3A;<strong>promise</strong>&#x5BF9;&#x8C61;&#xFF0C;&#x8FD4;&#x56DE;<strong>resolve</strong>&#x53C2;&#x6570;
 &#xFF08;2&#xFF09;<strong>await</strong>&#x53EF;&#x4EE5;&#x7B49;&#x5F85;&#x4EFB;&#x4F55;&#x4E1C;&#x897F;&#xFF0C;&#x5982;&#x679C;&#x7B49;&#x5F85;&#x7684;&#x662F;&#x666E;&#x901A;&#x5185;&#x5BB9;&#xFF0C;&#x5219;&#x76F4;&#x63A5;&#x8FD4;&#x56DE;&#x8BE5;&#x5185;&#x5BB9;</p>
<h4 id="&#x3010;&#x586B;&#x5751;1&#x3011;&#x5F02;&#x5E38;&#x5904;&#x7406;"><a name="&#x3010;&#x586B;&#x5751;1&#x3011;&#x5F02;&#x5E38;&#x5904;&#x7406;" class="anchor-navigation-ex-anchor" href="#&#x3010;&#x586B;&#x5751;1&#x3011;&#x5F02;&#x5E38;&#x5904;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x3010;&#x586B;&#x5751;1&#x3011;&#x5F02;&#x5E38;&#x5904;&#x7406;</h4>
<blockquote>
<p>&#x8BF7;&#x7528;<strong>try-catch</strong>&#x5904;&#x7406;&#x5F02;&#x5E38;&#x5185;&#x5BB9;</p>
</blockquote>
<p> &#x7EC6;&#x5FC3;&#x7684;&#x4F60;&#x5E94;&#x8BE5;&#x5DF2;&#x7ECF;&#x53D1;&#x73B0;&#xFF0C;<code>await</code> &#x8FD4;&#x56DE;&#x7684;&#x662F;promise&#x7684;<code>resolve</code>&#x53C2;&#x6570;&#xFF0C;&#x4F46;&#x5BF9;&#x4E8E;<code>catch</code>&#x5374;&#x6CA1;&#x6709;&#x5B9E;&#x9645;&#x7684;&#x5904;&#x7406;&#x3002;&#x90A3;&#x5F53;&#x6211;&#x4EEC;&#x7684;&#x8BF7;&#x6C42;&#x53D1;&#x751F;&#x5F02;&#x5E38;&#x65F6;&#xFF0C;&#x8BE5;&#x600E;&#x4E48;&#x529E;&#xFF1F;&#x7B54;&#x6848;&#x662F;&#x4F7F;&#x7528;<code>try-catch</code>&#xFF0C;&#x5728;Promise&#x4E2D;&#x7684;<code>.catch()</code>&#x5206;&#x652F;&#x4F1A;&#x6D41;&#x5165;<code>catch</code>&#x4E2D;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">asyncFunc</span>(<span class="hljs-params">time</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> {
    setTimeout(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> {  <span class="hljs-comment">// &#x7528;setTimeout&#x6A21;&#x62DF;&#x5F02;&#x6B65;</span>
      reject(<span class="hljs-string">&apos;promise reject&apos;</span>)
    }, time)
  })
}
<span class="hljs-comment">// &#x4E3A;&#x4E86;&#x5904;&#x7406;Promise.reject &#x7684;&#x60C5;&#x51B5;&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x5C06;&#x4EE3;&#x7801;&#x5757;&#x7528; try catch &#x6355;&#x83B7;&#x4E00;&#x4E0B;</span>
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">awaitDemo</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> asyncFunc(<span class="hljs-number">1000</span>)
    <span class="hljs-built_in">console</span>.log(res)
  } <span class="hljs-keyword">catch</span> (err) {
    <span class="hljs-built_in">console</span>.log(err.message || <span class="hljs-string">&apos;Uncatch Error&apos;</span>)
  }
}

awaitDemo()  <span class="hljs-comment">// &#x5982;&#x679C;&#x6CA1;&#x6709;&#x4F7F;&#x7528;try-catch&#xFF0C;&#x6267;&#x884C;&#x4F1A;&#x62A5;&#x9519;</span>
</code></pre>
<blockquote>
<p>&#x5751;1&#x5F88;&#x91CD;&#x8981;&#xFF0C;&#x8BF7;&#x8BA4;&#x8BC6;&#x6CE8;&#x91CD;&#x5F02;&#x5E38;&#x5904;&#x7406;&#x65B9;&#x5F0F;</p>
</blockquote>
<h4 id="&#x3010;&#x586B;&#x5751;2&#x3011;&#x5E76;&#x884C;&#x8BF7;&#x6C42;"><a name="&#x3010;&#x586B;&#x5751;2&#x3011;&#x5E76;&#x884C;&#x8BF7;&#x6C42;" class="anchor-navigation-ex-anchor" href="#&#x3010;&#x586B;&#x5751;2&#x3011;&#x5E76;&#x884C;&#x8BF7;&#x6C42;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x3010;&#x586B;&#x5751;2&#x3011;&#x5E76;&#x884C;&#x8BF7;&#x6C42;</h4>
<p> &#x5BF9;&#x4E8E;&#x4E00;&#x4E2A;&#x771F;&#x5B9E;&#x7684;&#x4E1A;&#x52A1;&#x9700;&#x6C42;&#xFF0C;&#x901A;&#x5E38;&#x4F1A;&#x6709;&#x591A;&#x4E2A;&#x5F02;&#x6B65;&#x8BF7;&#x6C42;&#x9700;&#x8981;&#x540C;&#x65F6;&#x6267;&#x884C;&#xFF0C;&#x5982;&#x83B7;&#x53D6;&#x5DE6;&#x4FA7;&#x76EE;&#x5F55;&#x6811;&#xFF0C;&#x548C;&#x767B;&#x5F55;&#x8D26;&#x6237;&#x7684;&#x7528;&#x6237;&#x4FE1;&#x606F;&#x7B49;&#x3002;&#x56E0;await&#x9047;&#x5230;&#x5F02;&#x6B65;&#x4F1A;&#x963B;&#x585E;&#xFF0C;&#x5F53;&#x4E00;&#x4E2A;async&#x51FD;&#x6570;&#x5185;&#x6709;&#x591A;&#x4E2A;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#x9700;&#x8981;&#x8C03;&#x7528;&#x65F6;&#xFF0C;&#x5C31;&#x4F1A;&#x51FA;&#x73B0;&#x76F8;&#x4E92;&#x7B49;&#x5F85;&#x7684;&#x73B0;&#x8C61;&#x3002;&#x5929;&#x54EA;&#xFF0C;<strong>&#x201C;&#x5F02;&#x6B65;&#x201D; &#x53D8;&#x6210;&#x4E86; &#x201C;&#x540C;&#x6B65;&#x201D;&#x4E86;</strong>&#xFF0C;&#x8FD9;&#x4E0D;&#x662F;&#x6211;&#x4EEC;&#x6240;&#x5E0C;&#x671B;&#x7684;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">asyncFunc</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> {
    setTimeout(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> {
      resolve(<span class="hljs-string">&apos;request done&apos;</span>)
    })
  })
}
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">bugDemo</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">await</span> asyncFunc()
  <span class="hljs-keyword">await</span> asyncFunc()
  <span class="hljs-keyword">await</span> asyncFunc()
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;finish&apos;</span>)
}
</code></pre>
<blockquote>
<p>&#x5386;&#x5BB3;&#x4E86;&#xFF0C;&#x53EF;&#x80FD;&#x7528;paomise.all() &#x628A;&#x5F02;&#x6B65;&#x53D8;&#x6210;&#x540C;&#x6B65;</p>
</blockquote>
<p>&#x4EE5;&#x4E0A;&#x4EE3;&#x7801;&#x6B63;&#x5E38;&#x6267;&#x884C;&#x4E86;&#xFF0C;&#x6CA1;&#x6709;&#x62A5;&#x51FA;&#x5F02;&#x5E38;&#xFF0C;&#x4F46;&#x4ED4;&#x7EC6;&#x89C2;&#x5BDF;&#x63A7;&#x5236;&#x53F0; timeline &#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;&#x4E09;&#x4E2A;&#x51FD;&#x6570;&#x662F;&#x540C;&#x6B65;&#x987A;&#x5E8F;&#x6267;&#x884C;&#x7684;&#xFF0C;&#x5176;&#x7F6A;&#x9B41;&#x7978;&#x9996;&#x5C31;&#x662F;<code>await</code>&#x7684;&#x7B49;&#x5F85;&#x673A;&#x5236;&#x3002;&#x90A3;&#x600E;&#x4E48;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF1F;</p>
<p>&#x2002; &#x5176;&#x5B9E;<code>async-await</code> &#x53EA;&#x662F;promise&#x7684;&#x8BED;&#x6CD5;&#x7CD6;&#xFF0C;&#x4F46;&#x5176;&#x5E76;&#x4E0D;&#x80FD;&#x4EE3;&#x66FF;Promise&#xFF0C;&#x4ECE;&#x5BF9;&#x5F02;&#x5E38;&#x7684;&#x5904;&#x7406;&#x4E0A;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x5F15;&#x5165;<code>try-catch</code> &#xFF0C;&#x672C;&#x95EE;&#x9898;&#x662F;&#x53E6;&#x4E00;&#x4E2A;&#x4F53;&#x73B0;&#x3002;&#x89E3;&#x51B3;&#x529E;&#x6CD5;&#x9700;&#x8981;&#x4F7F;&#x7528;promise&#x7684;<strong><code>.all()</code></strong></p>
<blockquote>
<p> <code>promise.all( iterable )</code>&#xFF0C;&#x5F53;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#x90FD;&#x4E3A;resolve&#x65F6;&#xFF0C;&#x8FD4;&#x56DE;<code>resolve</code>&#x72B6;&#x6001; </p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">correctDemo</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> f1 = asyncFunc()
  <span class="hljs-keyword">const</span> f2 = asyncFunc()
  <span class="hljs-keyword">const</span> f3 = asyncFunc()
  <span class="hljs-keyword">await</span> <span class="hljs-built_in">Promise</span>.all([f1, f2, f3]);
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;finish&apos;</span>)
}
</code></pre>
<blockquote>
<p>&#x725B;&#x903C;&#x5427;&#xFF0C;&#x8981;&#x7528;Promise.all&#x6765;&#x5904;&#x7406;&#x540C;&#x6B65;&#xFF0C;&#x4EC0;&#x4E48;&#x53EB;&#x540C;&#x6B65;&#xFF0C;&#x5C31;&#x662F;&#x66F4;&#x597D;&#x7684;&#x4F7F;&#x7528;&#x54AF;&#x3002;</p>
</blockquote>
<h4 id="&#x3010;&#x586B;&#x5751;3&#x3011;await&#x5FC5;&#x987B;&#x5728;async&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;"><a name="&#x3010;&#x586B;&#x5751;3&#x3011;await&#x5FC5;&#x987B;&#x5728;async&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;" class="anchor-navigation-ex-anchor" href="#&#x3010;&#x586B;&#x5751;3&#x3011;await&#x5FC5;&#x987B;&#x5728;async&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x3010;&#x586B;&#x5751;3&#x3011;await&#x5FC5;&#x987B;&#x5728;async&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;</h4>
<p> <code>await</code> &#x5E76;&#x4E0D;&#x53EA;&#x662F;&#x4F7F;&#x7528;&#x5728;<code>async</code> &#x51FD;&#x6570;&#x4E2D;&#x5373;&#x53EF;&#xFF0C;&#x8FD8;&#x5FC5;&#x987B;&#x5728;<code>asyn</code>&#x51FD;&#x6570;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x867D;&#x5728;async&#x51FD;&#x6570;&#x91CC;&#x4F7F;&#x7528;&#xFF0C;&#x4F46;&#x5728;forEach&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#xFF0C;&#x5F02;&#x5E38;</span>
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">errorDemo</span>(<span class="hljs-params"></span>) </span>{
    [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>].forEach(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> {
        <span class="hljs-keyword">await</span> item;
    });
}
errorDemo() <span class="hljs-comment">// SyntaxError: await is only valid in async function</span>
<span class="hljs-comment">// await &#x5FC5;&#x987B;&#x5728;async&#x51FD;&#x6570;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;</span>
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">correctDemo</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; arr.length; i ++) {
        <span class="hljs-keyword">await</span> arr[i];
    }
}
</code></pre>
<blockquote>
<p>&#x7406;&#x89E3;&#x6CA1;&#xFF0C;&#x6211;&#x611F;&#x89C9;&#x5230;&#xFF0C;&#x672C;&#x4EBA;&#x597D;&#x50CF;&#x7406;&#x89E3;&#xFF0C;&#x5BF9;&#xFF0C;&#x4E0D;&#x662F;&#x597D;&#x50CF;&#xFF0C;&#x662F;&#x5DF1;&#x7ECF;&#x638C;&#x63E1; </p>
</blockquote>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2019-11-27 10:00:35
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="常用的前端JavaScript方法封装.html" class="navigation navigation-prev " aria-label="Previous page: 常用的前端JavaScript方法封装">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="灵活运用JS开发技巧.html" class="navigation navigation-next " aria-label="Next page: 灵活运用JS开发技巧">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"异步神器Async Await介绍与填坑","level":"4.17","depth":1,"next":{"title":"灵活运用JS开发技巧","level":"4.18","depth":1,"path":"javaScript/灵活运用JS开发技巧.md","ref":"javaScript/灵活运用JS开发技巧.md","articles":[]},"previous":{"title":"常用的前端JavaScript方法封装","level":"4.16","depth":1,"path":"javaScript/常用的前端JavaScript方法封装.md","ref":"javaScript/常用的前端JavaScript方法封装.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"javaScript/异步神器Async-await介绍与填坑.md","mtime":"2019-11-27T02:00:35.751Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

